package com.lianqi.emcpframework.logging.autoconfigure;

import com.lianqi.emcpframework.logging.aop.AopInvokingLoggerSupport;
import com.lianqi.emcpframework.logging.aop.DefaultInvokingLoggerParser;
import com.lianqi.emcpframework.logging.aop.InvokingLoggerParser;
import com.lianqi.emcpframework.logging.aop.SwaggerLoggerParser;
import com.lianqi.emcpframework.logging.event.DefaultInvokingLoggerListener;
import com.lianqi.emcpframework.logging.event.InvokingLoggerListener;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.spring.web.SpringfoxWebMvcConfiguration;

/**
 * @program emcp-framework
 * @ClassName AopInvokLoggerConfigure
 * @description: aop方式方法调用自动注册类
 * @author: sky
 * @create: 2018/11/17 23:53
 */
@ConditionalOnClass(InvokingLoggerListener.class)
@Configuration
public class InvokingLoggerAutoConfigure {

    @Bean
    public InvokingLoggerListener defaultInvokLoggerListener(){
        return new DefaultInvokingLoggerListener();
    }
    @Bean
    public InvokingLoggerParser defaultInvokLoggerParser(){
        return new DefaultInvokingLoggerParser();
    }
    @Bean
    @ConditionalOnBean(SpringfoxWebMvcConfiguration.class)
    public InvokingLoggerParser swaggerInvokLoggerParser(){
        return new SwaggerLoggerParser();
    }
    @Bean
    public AopInvokingLoggerSupport invokLoggerSupport(){
        return new AopInvokingLoggerSupport();
    }

}
